'use strict';

var OFFLINE_APPID_MAP = {
	COMMON_RES: '60000099',
	MAIN_PAGE: '60000003',
	MENU_PAGE: '60000004',
	USER_MODULE: '60000006',
	MEAL_MODULE: '60000007',
	TRAVEL_MODULE: '60000008',
	HOTEL_MODULE: '60000009',
	NOVEL_MODULE: '60000011',
	BIG_SCREEN_MODULE: '60000010',
	ORDER_MODULE: '60000012',
	TIME_TABLE_MODULE: '60000013',
	WEATHER_MODULE: '60000014',
	TICKET_QUERY_MODULE: '60000015',
	TRAVEL_INFO_MODULE: '60000016',
	SHARE_VIEW_MODULE: '60000017'
};
var ZgtlUtils = function () {
	var MONTH_DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

	return {

		dateUtil: {
			// 是否闰年
			isLeapYear: function isLeapYear(y) {
				return y % 100 ? !(y % 4) : !(y % 400);
			},

			// 是否是日期类型
			isDate: function isDate(date) {
				return Object.prototype.toString.call(date) === '[object Date]';
			},
			// 是否是今天
			isToday: function isToday(today, date) {
				return ZgtlUtils.dateUtil.dateToString(ZgtlUtils.dateUtil.toDate(today || new Date())) === ZgtlUtils.dateUtil.dateToString(ZgtlUtils.dateUtil.toDate(date));
			},

			// 是否是明天
			isTomorrow: function isTomorrow(today, date) {
				today = ZgtlUtils.dateUtil.toDate(today || new Date());
				today.setDate(today.getDate() + 1);
				return ZgtlUtils.dateUtil.dateToString(today) === ZgtlUtils.dateUtil.dateToString(ZgtlUtils.dateUtil.toDate(date));
			},

			// 获取月份天数
			getMonthDays: function getMonthDays(y, m) {
				return m === 2 && ZgtlUtils.dateUtil.isLeapYear(y) ? MONTH_DAYS[m] + 1 : MONTH_DAYS[m];
			},

			// 补齐位数
			fixNum: function fixNum(n) {
				return n > 9 ? n : '0' + n;
			},

			// 字符串转成日期对象
			stringToDate: function stringToDate(date) {
				return new Date(date.replace(/-/gi, '/'));
			},

			// 日期对象转成字符串
			dateToString: function dateToString(date) {
				return ZgtlUtils.dateUtil.getDateInfo(date).dateStr;
			},

			// 转成日期对象
			toDate: function toDate(date) {
				return ZgtlUtils.dateUtil.isDate(date) ? date : ZgtlUtils.dateUtil.stringToDate(date);
			},

			// 加天数
			addDate: function addDate(date, diff) {
				date = ZgtlUtils.dateUtil.toDate(ZgtlUtils.dateUtil.dateToString(date));
				date.setDate(date.getDate() + diff);
				return ZgtlUtils.dateUtil.dateToString(date);
			},

			// 获取年份
			getYear: function getYear(date) {
				return ZgtlUtils.dateUtil.toDate(date).getFullYear();
			},

			// 获取月份
			getMonth: function getMonth(date) {
				return ZgtlUtils.dateUtil.toDate(date).getMonth() + 1;
			},

			// 获取几号
			getDate: function getDate(date) {
				return ZgtlUtils.dateUtil.toDate(date).getDate();
			},

			// 获取周几
			getWeekDay: function getWeekDay(date) {
				return ZgtlUtils.dateUtil.toDate(date).getDay();
			},

			// 获取日期信息对象
			getDateInfo: function getDateInfo(date) {
				var dateObj = ZgtlUtils.dateUtil.toDate(date);
				var dateInfo = {
					year: dateObj.getFullYear(),
					month: dateObj.getMonth() + 1,
					date: dateObj.getDate(),
					day: dateObj.getDay()
				};

				return dateInfo;
			}
		},
		typeUtil: {
			typeOf: function typeOf(v) {
				return Object.prototype.toString.call(v).slice(8, -1).toLowerCase();
			},
			isString: function isString(v) {
				return typeof v === 'string';
			},

			isNumber: function isNumber(v) {
				return typeof v === 'number';
			},

			isBoolean: function isBoolean(v) {
				return typeof v === 'boolean';
			},

			isFunction: function isFunction(v) {
				return typeof v === 'function';
			},

			isUndefined: function isUndefined(v) {
				return typeof v === 'undefined';
			},

			isNull: function isNull(v) {
				return v === null;
			},

			isArray: function isArray(v) {
				return Array.isArray ? Array.isArray(v) : typeOf(v) === 'array';
			},

			isObject: function isObject(v) {
				return ZgtlUtils.typeUtil.typeOf(v) === 'object';
			},

			isRegExp: function isRegExp(v) {
				return ZgtlUtils.typeUtil.typeOf(v) === 'regexp';
			},

			isDate: function isDate(v) {
				return ZgtlUtils.typeUtil.typeOf(v) === 'date';
			},

			isValue: function isValue(v) {
				var t = ZgtlUtils.typeUtil.typeOf(v);

				switch (t) {
					case 'number':
						return ZgtlUtils.typeUtil.isFinite(v);
					case 'null':
					case 'undefined':
						return false;
					default:
						return !!t;
				}
			},
			objectEach: function objectEach(obj, callback, ignoreUndefined) {
				if (!obj || !callback) {
					return;
				}
				var ret = false;

				for (var k in obj) {
					if (obj.hasOwnProperty(k) && !(ignoreUndefined && this.isUndefined(obj[k]))) {
						ret = callback(obj[k], k);
						if (ret) break;
					}
				}
			},
			tryParse: function tryParse(v, each) {
				if (each && ZgtlUtils.typeUtil.isObject(v)) {
					var r = {};
					ZgtlUtils.typeUtil.objectEach(v, function (ov, k) {
						r[k] = ZgtlUtils.typeUtil.tryParse(ov);
					});
					return r;
				} else {
					var _r = v;
					if (v && ZgtlUtils.typeUtil.isString(v)) {
						if (/^[\{\[].*/.test(v) || v === 'null' || v === 'undefined' || v === 'true' || v === 'false') {
							try {
								_r = v ? JSON.parse(v) : v;
							} catch (err) {
								_r = v;
							}
						}
					}
					return _r;
				}
			}
		},
		platform: function platform() {
			var ua = window.navigator.userAgent;
			// os
			var ios = false;
			var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
			var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
			var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
			var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
			// version
			var version = '';
			android && (version = android[2]) && (android = true);
			iphone && !ipod && (version = iphone[2].replace(/_/g, '.')) && (ios = iphone = true);
			ipad && (version = ipad[2].replace(/_/g, '.')) && (ios = ipad = true);
			ipod && (version = ipod[3] ? ipod[3].replace(/_/g, '.') : '') && (ios = ipod = true);
			// native
			// let clientVersion = '';
			// let client = ua.match(/(mobile12306)\s+([\d.]+)/i);
			// client && (clientVersion = client ? client[2] : '') && (client = true);
			return ios ? 'ios' : android ? 'android' : 'web';
		},
		// 是否是12306客户端
		isKp: function isKp() {
			return (/mobile12306/i.test(window.navigator.userAgent)
			);
		}
	};
}();
var ZgtlMpaasUtil = function () {
	function log() {
		for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
			args[_key] = arguments[_key];
		}

		console.log('[ZgtlMpaasUtil LOG]', args);
	}
	function ready(callback) {
		// 如果jsbridge已经注入则直接调用
		if (window.AlipayJSBridge) {
			callback && callback();
		} else {
			// 如果没有注入则监听注入的事件
			document.addEventListener('AlipayJSBridgeReady', function handler() {
				document.removeEventListener('AlipayJSBridgeReady', handler, false);
				callback();
			}, false);
		}
	}
	function call() {
		for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
			args[_key2] = arguments[_key2];
		}

		ready(function () {
			// log('[CALL]', args);
			window.AlipayJSBridge.call.apply(window.AlipayJSBridge, args);
		});
	}
	function close() {
		call('popWindow', { animationType: 'none' });
	}
	function handleCallback(_ref) {
		var data = _ref.data,
		    callback = _ref.callback;

		// log('[HANDLE]', data);
		if (data && ZgtlUtils.typeUtil.isString(data)) {
			try {
				data = JSON.parse(data);
			} catch (err) {
				// data = res;
				console.log('HANDLE PARSE JSON ERR', err);
			}
		}
		if (data && ZgtlUtils.typeUtil.isObject(data)) {
			data = ZgtlUtils.typeUtil.tryParse(data, true);
		}
		callback(data);
	}
	return {
		/**
   * 同一appid包打开新页面
   * @param verify 是否需要登录
   * @param url 网址如: #/aabbcc?param=value&param2=value2 
   * @param onResume 回调函数(仅在closeSelf=false时有效)
   */
		pushWindow: function pushWindow(_ref2) {
			var _ref2$verify = _ref2.verify,
			    verify = _ref2$verify === undefined ? false : _ref2$verify,
			    _ref2$url = _ref2.url,
			    url = _ref2$url === undefined ? '' : _ref2$url,
			    _ref2$gestureBack = _ref2.gestureBack,
			    gestureBack = _ref2$gestureBack === undefined ? true : _ref2$gestureBack,
			    _ref2$onResume = _ref2.onResume,
			    onResume = _ref2$onResume === undefined ? function () {} : _ref2$onResume;

			if (ZgtlUtils.isKp()) {
				verify = false;
			}
			var param = {
				url: url,
				showProgress: true,
				closeCurrentWindow: false,
				showLoading: false,
				showTitlebar: false,
				readTitle: false,
				showToolBar: false,
				showOptionMenu: false,
				gestureBack: gestureBack,
				param: {
					gestureBack: gestureBack,
					showProgress: true,
					closeCurrentWindow: false,
					showLoading: false,
					showTitlebar: false,
					readTitle: false,
					showToolBar: false,
					showOptionMenu: false
				}
			};
			if (ZgtlUtils.platform() == 'android') {
				url = location.href.substring(0, location.href.indexOf('#')) + url;
				// alert('PARAM: ' + JSON.stringify(param));
				param.url = url;
			}
			if (verify) {
				ZgtlAppLogic.getCachedToken({
					success: function success() {
						var pluginName = 'pushWindow';
						call(pluginName, param, function (data) {
							handleCallback({ data: data, callback: callback });
						});
						document.addEventListener('resume', function handler(event) {
							onResume(event.data);
							document.removeEventListener('resume', handler);
						});
					},
					error: function error() {
						//本地校验失败
						ZgtlMpaasUtil.startH5App({
							appId: OFFLINE_APPID_MAP.USER_MODULE,
							url: '/www/index.html#/login'
						});
					}
				});
			} else {
				var pluginName = 'pushWindow';
				call(pluginName, param, function (data) {
					handleCallback({ data: data, callback: callback });
				});
				document.addEventListener('resume', function handler(event) {
					onResume(event.data);
					document.removeEventListener('resume', handler);
				});
			}
		},
		/**
   * 打开新appid包页面
   * @param verify 是否需要登录
   * @param url 网址如: #/aabbcc?param=value&param2=value2 
   * @param closeSelf true/false 打开新页面时是否关闭当前页面
   * @param onResume 回调函数(仅在closeSelf=false时有效)
   * @param callback 失败时候的回调
   */
		startH5App: function startH5App(_ref3) {
			var _ref3$verify = _ref3.verify,
			    verify = _ref3$verify === undefined ? false : _ref3$verify,
			    _ref3$appId = _ref3.appId,
			    appId = _ref3$appId === undefined ? '' : _ref3$appId,
			    _ref3$url = _ref3.url,
			    url = _ref3$url === undefined ? '' : _ref3$url,
			    _ref3$gestureBack = _ref3.gestureBack,
			    gestureBack = _ref3$gestureBack === undefined ? true : _ref3$gestureBack,
			    _ref3$closeSelf = _ref3.closeSelf,
			    closeSelf = _ref3$closeSelf === undefined ? false : _ref3$closeSelf,
			    _ref3$onResume = _ref3.onResume,
			    onResume = _ref3$onResume === undefined ? function () {} : _ref3$onResume,
			    _ref3$callback = _ref3.callback,
			    callback = _ref3$callback === undefined ? function () {} : _ref3$callback;

			if (ZgtlUtils.isKp()) {
				verify = false;
			}
			var param = {
				appId: appId + '',
				url: url,
				showTitleBar: false,
				appClearTop: false,
				startMultApp: 'YES',
				gestureBack: gestureBack,
				param: {
					url: url,
					gestureBack: gestureBack,
					showTitlebar: false,
					showLoading: false,
					showTitleBar: false,
					transparentTitle: 'auto',
					appClearTop: false,
					startMultApp: 'YES'
				}
			};
			var pluginName = 'startApp';
			if (ZgtlUtils.platform() == 'android') {
				if (appId + '' == '60000006') {
					pluginName = 'startH5App';
					param = {
						appId: appId + '',
						url: url,
						showProgress: false,
						closeCurrentWindow: false,
						showLoading: false,
						showTitlebar: false,
						showTitleBar: false,
						readTitle: false,
						showToolBar: false,
						showOptionMenu: false,
						backBehavior: 'back',
						param: {
							showProgress: false,
							closeCurrentWindow: false,
							showLoading: false,
							showTitlebar: false,
							showTitleBar: false,
							backBehavior: 'back',
							readTitle: false,
							showToolBar: false,
							showOptionMenu: false
						}
					};
				}
				// alert('START H5 PARAM: ' + JSON.stringify(param));
				//  pluginName = 'customStartH5App';
			}
			if (verify) {
				ZgtlAppLogic.getCachedToken({
					success: function success() {
						if (url.indexOf('?') > 0) {
							url = url + '&__cross_app_passing=true';
						} else {
							url = url + '?__cross_app_passing=true';
						}
						ZgtlUtils.platform() == 'ios' && closeSelf && call('closeCurrentPage');
						call(pluginName, param, function (data) {
							handleCallback({ data: data, callback: callback });
						});
						if (!closeSelf) {
							document.addEventListener('resume', function handler(event) {
								onResume(event.data);
								document.removeEventListener('resume', handler);
							});
						}
						ZgtlUtils.platform() == 'android' && closeSelf && close();
					},
					error: function error() {
						//本地校验失败
						ZgtlMpaasUtil.startH5App({
							appId: OFFLINE_APPID_MAP.USER_MODULE,
							url: '/www/index.html#/login'
						});
					}
				});
				return;
			} else {
				if (url.indexOf('?') > 0) {
					url = url + '&__cross_app_passing=true';
				} else {
					url = url + '?__cross_app_passing=true';
				}
				ZgtlUtils.platform() == 'ios' && closeSelf && call('closeCurrentPage');
				call(pluginName, param, function (data) {
					handleCallback({ data: data, callback: callback });
				});
				if (!closeSelf) {
					document.addEventListener('resume', function handler(event) {
						onResume(event.data);
						document.removeEventListener('resume', handler);
					});
				}
				ZgtlUtils.platform() == 'android' && closeSelf && close();
			}
		},
		/**
   * 关闭当前窗口
   */
		popWindow: function popWindow() {
			// let resumeData = data;
			// resumeData.href = location.href;
			call('popWindow');
		},
		/**
   * 关闭当前H5容器
   */
		exitApp: function exitApp() {
			ZgtlUtils.platform() == 'ios' ? call('closeCurrentPage') : close();
		},
		/**
   * 关闭其它H5容器
   */
		closeOtherH5Page: function closeOtherH5Page() {
			call('closeOtherH5Page');
		},
		/**
   * 关闭至前N个窗口
   * @param data 往上一个页面的回调
   * @param index -1时等同于popWindow
   * @param callback 失败时候的回调
   */
		popToByUrlPattern: function popToByUrlPattern(_ref4) {
			var _ref4$urlPattern = _ref4.urlPattern,
			    urlPattern = _ref4$urlPattern === undefined ? '' : _ref4$urlPattern,
			    _ref4$callback = _ref4.callback,
			    callback = _ref4$callback === undefined ? function () {} : _ref4$callback;

			// let resumeData = data;
			// resumeData.href = location.href;
			call('popTo', {
				urlPattern: urlPattern // 回退到上一个页面，假如这个时候没有上一个页面，就会报错
				// data: resumtData
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 关闭至前N个窗口
   * @param data 往上一个页面的回调
   * @param index -1时等同于popWindow
   * @param callback 失败时候的回调
   */
		popTo: function popTo(_ref5) {
			var _ref5$index = _ref5.index,
			    index = _ref5$index === undefined ? -1 : _ref5$index,
			    _ref5$callback = _ref5.callback,
			    callback = _ref5$callback === undefined ? function () {} : _ref5$callback;

			// let resumeData = data;
			// resumeData.href = location.href;
			call('popTo', {
				index: index // 回退到上一个页面，假如这个时候没有上一个页面，就会报错
				// data: resumtData
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 保存至本地缓存
   * @param key key
   * @param value 值
   * @param callback 回调函数
   */
		setAPDataStorage: function setAPDataStorage(_ref6) {
			var _ref6$key = _ref6.key,
			    key = _ref6$key === undefined ? '' : _ref6$key,
			    _ref6$value = _ref6.value,
			    value = _ref6$value === undefined ? '' : _ref6$value,
			    _ref6$callback = _ref6.callback,
			    callback = _ref6$callback === undefined ? function () {} : _ref6$callback;

			call('setAPDataStorage', {
				type: 'common',
				business: 'tielvMsg',
				key: key,
				value: value
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 从本地缓存获取
   * @param key key
   * @param callback 回调函数 参数内是值
   */
		getAPDataStorage: function getAPDataStorage(_ref7) {
			var _ref7$key = _ref7.key,
			    key = _ref7$key === undefined ? '' : _ref7$key,
			    _ref7$callback = _ref7.callback,
			    callback = _ref7$callback === undefined ? function () {} : _ref7$callback;

			call('getAPDataStorage', {
				type: 'common',
				business: 'tielvMsg',
				key: key
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 从本地缓存删除
   * @param key key
   * @param callback 回调函数
   */
		removeAPDataStorage: function removeAPDataStorage(_ref8) {
			var _ref8$key = _ref8.key,
			    key = _ref8$key === undefined ? '' : _ref8$key,
			    _ref8$callback = _ref8.callback,
			    callback = _ref8$callback === undefined ? function () {} : _ref8$callback;

			call('removeAPDataStorage', {
				type: 'common',
				business: 'tielvMsg',
				key: key
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 显示本地安装的地图并导航
   * @param lat 纬度
   * @param lng 经度
   * @param callback 回调函数
   */
		getDeviceMapAppList: function getDeviceMapAppList(_ref9) {
			var _ref9$lat = _ref9.lat,
			    lat = _ref9$lat === undefined ? '' : _ref9$lat,
			    _ref9$lng = _ref9.lng,
			    lng = _ref9$lng === undefined ? '' : _ref9$lng,
			    _ref9$address = _ref9.address,
			    address = _ref9$address === undefined ? '' : _ref9$address,
			    _ref9$callback = _ref9.callback,
			    callback = _ref9$callback === undefined ? function () {} : _ref9$callback;

			call('getDeviceMapAppList', {
				lat: lat,
				lng: lng,
				address: address
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 调用本地电话
   * @param phoneNumber 电话号码
   */
		makeCall: function makeCall(_ref10) {
			var _ref10$phoneNumber = _ref10.phoneNumber,
			    phoneNumber = _ref10$phoneNumber === undefined ? '' : _ref10$phoneNumber;

			call('makeCall', { phoneNum: phoneNumber }, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 获取系统信息
   * @param callback 回调函数,参数内是数据
   */
		getAppBaseInfo: function getAppBaseInfo(_ref11) {
			var _ref11$callback = _ref11.callback,
			    callback = _ref11$callback === undefined ? function () {} : _ref11$callback;

			call('getAppBaseInfo', {}, function (data) {
				// test
				// if (!data.error) {
				// 	data.appVer = '5.0.0';
				// }
				// test
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 微信是否安装
   */
		isWxInstalled: function isWxInstalled(_ref12) {
			var _ref12$callback = _ref12.callback,
			    callback = _ref12$callback === undefined ? function () {} : _ref12$callback;

			call('isWxInstalled', {}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 获取经纬度信息
   * @param cache 是否优先缓存
   * @param callback 回调函数,参数内是数据
   */
		getCurrentPosition: function getCurrentPosition(_ref13) {
			var _ref13$cache = _ref13.cache,
			    cache = _ref13$cache === undefined ? false : _ref13$cache,
			    _ref13$callback = _ref13.callback,
			    callback = _ref13$callback === undefined ? function () {} : _ref13$callback;

			var that = this;
			if (cache) {
				this.getAPDataStorage({
					key: 'KEY_POS_CACHE',
					callback: function (_callback) {
						function callback(_x) {
							return _callback.apply(this, arguments);
						}

						callback.toString = function () {
							return _callback.toString();
						};

						return callback;
					}(function (result) {
						if (!result.data) {
							call('getCurrentPosition', {}, function (data) {
								if (!data.error) {
									try {
										that.setAPDataStorage({
											key: 'KEY_POS_CACHE',
											value: JSON.stringify({
												lat: data.lat,
												lng: data.lng,
												timestamp: new Date().getTime()
											})
										});
									} catch (e) {}
								}
								handleCallback({ data: data, callback: callback });
							});
						} else {
							var currentTimestamp = new Date().getTime();
							if (currentTimestamp - result.data.timestamp < 1800000) {
								var cacheResult = {
									success: 'true',
									lat: result.data.lat,
									lng: result.data.lng
								};
								handleCallback({ data: cacheResult, callback: callback });
								call('getCurrentPosition', {}, function (data) {
									if (!data.error) {
										try {
											that.setAPDataStorage({
												key: 'KEY_POS_CACHE',
												value: JSON.stringify({
													lat: data.lat,
													lng: data.lng,
													timestamp: new Date().getTime()
												})
											});
										} catch (e) {}
									}
								});
							} else {
								call('getCurrentPosition', {}, function (data) {
									if (!data.error) {
										try {
											that.setAPDataStorage({
												key: 'KEY_POS_CACHE',
												value: JSON.stringify({
													lat: data.lat,
													lng: data.lng,
													timestamp: new Date().getTime()
												})
											});
										} catch (e) {}
									}
									handleCallback({ data: data, callback: callback });
								});
							}
						}
					})
				});
			} else {
				call('getCurrentPosition', {}, function (data) {
					if (!data.error) {
						try {
							that.setAPDataStorage({
								key: 'KEY_POS_CACHE',
								value: JSON.stringify({
									lat: data.lat,
									lng: data.lng,
									timestamp: new Date().getTime()
								})
							});
						} catch (e) {}
					}
					handleCallback({ data: data, callback: callback });
				});
			}
		},
		/**
   * 扫码
   * @param callback 回调函数,参数内是数据
   */
		scanQRCode: function scanQRCode(_ref14) {
			var _ref14$callback = _ref14.callback,
			    callback = _ref14$callback === undefined ? function () {} : _ref14$callback;

			call('scanQRCode', {}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 获取阿里云的控制参数
   * @param key key
   * @param callback 回调函数
   */
		getConfig: function getConfig(_ref15) {
			var _ref15$key = _ref15.key,
			    key = _ref15$key === undefined ? '' : _ref15$key,
			    _ref15$callback = _ref15.callback,
			    callback = _ref15$callback === undefined ? function () {} : _ref15$callback;

			call('getConfig', {
				getConfigKey: key
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 拉起微信支付
   * @param data 表单
   * @param signMsg 签名
   * @param callback 回调函数
   */
		doWechatPay: function doWechatPay(_ref16) {
			var _ref16$data = _ref16.data,
			    data = _ref16$data === undefined ? '' : _ref16$data,
			    _ref16$signMsg = _ref16.signMsg,
			    signMsg = _ref16$signMsg === undefined ? '' : _ref16$signMsg,
			    _ref16$callback = _ref16.callback,
			    callback = _ref16$callback === undefined ? function () {} : _ref16$callback;

			call('doWechatPay', {
				data: data,
				signMsg: signMsg
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 拉起支付宝支付
   * @param data 表单
   * @param signMsg 签名
   * @param callback 回调函数
   */
		doAliPay: function doAliPay(_ref17) {
			var _ref17$data = _ref17.data,
			    data = _ref17$data === undefined ? '' : _ref17$data,
			    _ref17$signMsg = _ref17.signMsg,
			    signMsg = _ref17$signMsg === undefined ? '' : _ref17$signMsg,
			    _ref17$callback = _ref17.callback,
			    callback = _ref17$callback === undefined ? function () {} : _ref17$callback;

			call('doAliPay', {
				data: data,
				signMsg: signMsg
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 京东支付
   * @param merchant 商户id '112045173001 = 餐饮, 112045173002 = 酒店'
   * @param appid appid 'jdjr112045173003 = 餐饮, jdjr112045173007 = 酒店' 
   * @param orderId 订单id
   * @param signData 签名
   * @param callback 回调函数
   */
		doJdPay: function doJdPay(_ref18) {
			var _ref18$merchant = _ref18.merchant,
			    merchant = _ref18$merchant === undefined ? '112045173001' : _ref18$merchant,
			    _ref18$appId = _ref18.appId,
			    appId = _ref18$appId === undefined ? 'jdjr112045173003' : _ref18$appId,
			    _ref18$orderId = _ref18.orderId,
			    orderId = _ref18$orderId === undefined ? '' : _ref18$orderId,
			    _ref18$signData = _ref18.signData,
			    signData = _ref18$signData === undefined ? '' : _ref18$signData,
			    _ref18$callback = _ref18.callback,
			    callback = _ref18$callback === undefined ? function () {} : _ref18$callback;

			call('doJdPay', {
				appId: appId,
				merchant: merchant,
				orderId: orderId,
				signData: signData
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 分享页面
   * @param title 标题
   * @param content 内容
   * @param url 跳转地址
   * @param image 图片
   * @param callback 回调函数
   */
		shareWeb: function shareWeb(_ref19) {
			var _ref19$title = _ref19.title,
			    title = _ref19$title === undefined ? '' : _ref19$title,
			    _ref19$content = _ref19.content,
			    content = _ref19$content === undefined ? '' : _ref19$content,
			    _ref19$url = _ref19.url,
			    url = _ref19$url === undefined ? '' : _ref19$url,
			    _ref19$image = _ref19.image,
			    image = _ref19$image === undefined ? '' : _ref19$image,
			    _ref19$callback = _ref19.callback,
			    callback = _ref19$callback === undefined ? function () {} : _ref19$callback;

			call('shareWeb', {
				title: title,
				content: content,
				image: image,
				url: url
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 获取请求头
   */
		getRequestHeader: function getRequestHeader(_ref20) {
			var _ref20$callback = _ref20.callback,
			    callback = _ref20$callback === undefined ? function () {} : _ref20$callback;

			this.getAppBaseInfo({
				callback: function (_callback2) {
					function callback(_x2) {
						return _callback2.apply(this, arguments);
					}

					callback.toString = function () {
						return _callback2.toString();
					};

					return callback;
				}(function (data) {
					var appBaseInfo = {};
					if (!data.error) {
						appBaseInfo.appVer = data.appVer;
						appBaseInfo.devId = data.devId;
					} else {
						appBaseInfo = {
							appVer: '5.0.0',
							devId: '--'
						};
					}
					var devOs = ZgtlUtils.platform();
					var header = {
						'User-Agent': 'ZTCTL/' + devOs + '/' + appBaseInfo.appVer,
						appVer: '' + appBaseInfo.appVer,
						'Content-Type': 'application/x-www-form-urlencoded',
						devOs: '' + devOs,
						devId: '' + appBaseInfo.devId
					};
					ZgtlAppLogic.getCachedToken({
						success: function success(token) {
							header.accessToken = token;
							callback(header);
						},
						error: function error() {
							callback(header);
						}
					});
				})
			});
		},
		/**
   * 打开第三方页面
   * @param url 跳转地址
   * @param callback 回调函数
   */
		openOutURL: function openOutURL(_ref21) {
			var _ref21$url = _ref21.url,
			    url = _ref21$url === undefined ? '' : _ref21$url,
			    _ref21$showTitleBar = _ref21.showTitleBar,
			    showTitleBar = _ref21$showTitleBar === undefined ? true : _ref21$showTitleBar,
			    _ref21$title = _ref21.title,
			    title = _ref21$title === undefined ? '' : _ref21$title,
			    _ref21$callback = _ref21.callback,
			    callback = _ref21$callback === undefined ? function () {} : _ref21$callback;

			if (url == '' || url == undefined) {
				callback({ error: '9', errorMessage: '未给定地址' });
				return;
			}
			if (showTitleBar) {
				if (url.indexOf('?') > 0) {
					url = url + '&ZGTL_SHOWTITLE';
				} else {
					url = url + '?ZGTL_SHOWTITLE';
				}
			}

			call('openOutURL', { url: url, showTitleBar: showTitleBar, title: title }, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},

		/**
   * 打开相机
   * @param isCompress 是否压缩
   * @param comPressToSize 压缩至 xxKb
   * @param callback 回调函数
   */
		openCamera: function openCamera(_ref22) {
			var _ref22$isCompress = _ref22.isCompress,
			    isCompress = _ref22$isCompress === undefined ? true : _ref22$isCompress,
			    _ref22$comPressToSize = _ref22.comPressToSize,
			    comPressToSize = _ref22$comPressToSize === undefined ? 100 : _ref22$comPressToSize,
			    _ref22$callback = _ref22.callback,
			    callback = _ref22$callback === undefined ? function () {} : _ref22$callback;

			call('openCamera', {
				isCompress: isCompress,
				comPressToSize: comPressToSize
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 返回首页并定位到index
   * @param index tab页index
   */
		startLauncher: function startLauncher(_ref23) {
			var _ref23$index = _ref23.index,
			    index = _ref23$index === undefined ? 0 : _ref23$index;

			call('startLauncher', { index: index });
		},
		/**
   * 注册极光Aalias
   * @param alias 用户id
   * @param callback 回调函数
   */
		registerJPushAlias: function registerJPushAlias(_ref24) {
			var _ref24$alias = _ref24.alias,
			    alias = _ref24$alias === undefined ? '' : _ref24$alias,
			    _ref24$callback = _ref24.callback,
			    callback = _ref24$callback === undefined ? function () {} : _ref24$callback;

			call('registerJPushAlias', {
				alias: alias
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 注销极光Aalias
   * @param alias 用户id
   * @param callback 回调函数
   */
		unRegisterJPushAlias: function unRegisterJPushAlias(_ref25) {
			var _ref25$alias = _ref25.alias,
			    alias = _ref25$alias === undefined ? '' : _ref25$alias,
			    _ref25$callback = _ref25.callback,
			    callback = _ref25$callback === undefined ? function () {} : _ref25$callback;

			call('unRegisterJPushAlias', {
				alias: alias
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * http请求
   * @param url 请求地址
   * @param method GET/POST
   * @param param 参数
   * @param callback 回调函数,返回结果
   */
		httpRequest: function httpRequest(_ref26) {
			var _ref26$url = _ref26.url,
			    url = _ref26$url === undefined ? '' : _ref26$url,
			    _ref26$method = _ref26.method,
			    method = _ref26$method === undefined ? '' : _ref26$method,
			    _ref26$param = _ref26.param,
			    param = _ref26$param === undefined ? {} : _ref26$param,
			    _ref26$callback = _ref26.callback,
			    callback = _ref26$callback === undefined ? function () {} : _ref26$callback;

			log('httpRequest', url, method, param, callback);
			method = method.toUpperCase();
			this.getRequestHeader({
				callback: function (_callback3) {
					function callback(_x3) {
						return _callback3.apply(this, arguments);
					}

					callback.toString = function () {
						return _callback3.toString();
					};

					return callback;
				}(function (header) {
					call('httpRequest', {
						url: url,
						method: method,
						header: header,
						param: param
					}, function (data) {
						handleCallback({
							data: data,
							callback: function (_callback4) {
								function callback(_x4) {
									return _callback4.apply(this, arguments);
								}

								callback.toString = function () {
									return _callback4.toString();
								};

								return callback;
							}(function (data) {
								if (data.error) {
									if (data.error == '400') {
										callback({ error: '400', errorMessage: '参数非法' });
									} else if (data.error == '500') {
										callback({ error: '500', errorMessage: '服务器异常' });
									} else if (data.error == '404') {
										callback({ error: '404', errorMessage: '无效Url' });
									} else if (data.error == '405') {
										callback({ error: '405', errorMessage: '请求方法错误' });
									} else if (data.error == '502') {
										callback({ error: '502', errorMessage: '网关错误' });
									} else if (data.error == '504') {
										callback({ error: '504', errorMessage: '网关超时' });
									} else if (data.error == '999') {
										callback({ error: '999', errorMessage: '网络中断' });
									} else if (data.error == '998') {
										callback({ error: '998', errorMessage: '请求超时' });
									} else if (data.error == '997') {
										callback({
											error: '997',
											errorMessage: '应用检测到您的手机运行环境可能存在安全隐患，为确保您的隐私安全，请检查后重试。'
										});
									} else if (data.error == '401') {
										ZgtlAppLogic.handle401();
										callback({ error: '401', errorMessage: '无效授权' });
									} else {
										callback(data);
									}
								} else {
									callback(data);
								}
							})
						});
					});
				})
			});
		},
		/**
   * 移除事件监听
   * @param name 事件名,不带NEBULANOTIFY头
   */
		removeNotifyListener: function removeNotifyListener(_ref27) {
			var _ref27$name = _ref27.name,
			    name = _ref27$name === undefined ? '' : _ref27$name,
			    _ref27$callback = _ref27.callback,
			    callback = _ref27$callback === undefined ? function () {} : _ref27$callback;

			if (name == '') {
				callback({ success: false, error: '9', errorMessage: '未给定通知名称' });
				return;
			}
			name = 'NEBULANOTIFY_' + name;
			call('removeNotifyListener', {
				name: name
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 添加事件监听
   * @param name 事件名,不带NEBULANOTIFY头
   */
		addNotifyListener: function addNotifyListener(_ref28) {
			var _ref28$name = _ref28.name,
			    name = _ref28$name === undefined ? '' : _ref28$name,
			    _ref28$callback = _ref28.callback,
			    callback = _ref28$callback === undefined ? function () {} : _ref28$callback;

			if (name == '') {
				callback({ success: false, error: '9', errorMessage: '未给定通知名称' });
				return;
			}
			this.removeNotifyListener({ name: name });
			name = 'NEBULANOTIFY_' + name;
			call('addNotifyListener', {
				name: name
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 发布事件
   * @param name 事件名,不带NEBULANOTIFY头
   * @param data 事件参数
   */
		postNotification: function postNotification(_ref29) {
			var _ref29$name = _ref29.name,
			    name = _ref29$name === undefined ? '' : _ref29$name,
			    _ref29$data = _ref29.data,
			    data = _ref29$data === undefined ? {} : _ref29$data,
			    _ref29$callback = _ref29.callback,
			    callback = _ref29$callback === undefined ? function () {} : _ref29$callback;

			if (name == '') {
				callback({ success: false, error: '9', errorMessage: '未给定通知名称' });
				return;
			}
			call('postNotification', {
				name: name,
				data: data
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 打开导航SDK
   * @param callback 回调函数
   */
		openStationNav: function openStationNav(_ref30) {
			var _ref30$stationTelecod = _ref30.stationTelecode,
			    stationTelecode = _ref30$stationTelecod === undefined ? '' : _ref30$stationTelecod,
			    _ref30$entryPage = _ref30.entryPage,
			    entryPage = _ref30$entryPage === undefined ? '' : _ref30$entryPage,
			    _ref30$callback = _ref30.callback,
			    callback = _ref30$callback === undefined ? function () {} : _ref30$callback;

			call('openStationNav', {
				stationTelecode: stationTelecode,
				entryPage: entryPage
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 注册mPaas 用户id
   * @param userId 用户Id
   * @param callback 回调函数
   */
		registerMpaasUserId: function registerMpaasUserId(_ref31) {
			var _ref31$userId = _ref31.userId,
			    userId = _ref31$userId === undefined ? '' : _ref31$userId,
			    _ref31$callback = _ref31.callback,
			    callback = _ref31$callback === undefined ? function () {} : _ref31$callback;

			if (ZgtlUtils.platform() != 'android') {
				return;
			}
			if (userId == null || userId == undefined || userId == '') {
				callback({ success: false, error: '9', errorMessage: '未给userId名称' });
				return;
			} else {
				call('registerMpaasUserId', {
					userId: userId
				}, function (data) {
					handleCallback({ data: data, callback: callback });
				});
			}
		},
		/**
   * 自定义actionCode
   * @param title 标题
   * @param btns 按钮
   * @param cancelButton 取消按钮的文字
   */
		customActionSheet: function customActionSheet(_ref32) {
			var _ref32$title = _ref32.title,
			    title = _ref32$title === undefined ? '请选择' : _ref32$title,
			    _ref32$btns = _ref32.btns,
			    btns = _ref32$btns === undefined ? [] : _ref32$btns,
			    _ref32$cancelButton = _ref32.cancelButton,
			    cancelButton = _ref32$cancelButton === undefined ? '取消' : _ref32$cancelButton,
			    _ref32$callback = _ref32.callback,
			    callback = _ref32$callback === undefined ? function () {} : _ref32$callback;

			if (btns != undefined && btns.length > 0) {
				call('customActionSheet', {
					title: title,
					btns: btns,
					cancelButton: cancelButton
				}, function (data) {
					handleCallback({ data: data, callback: callback });
				});
			} else {
				callback({ success: false, error: '9', errorMessage: '未给定按钮数据' });
			}
		},
		/**
   * 拉起12306校验SDK
   * @param callback
   */
		pullUpKpAuth: function pullUpKpAuth(_ref33) {
			var _ref33$callback = _ref33.callback,
			    callback = _ref33$callback === undefined ? function () {} : _ref33$callback;

			var that = this;
			call('pullUpKpAuth', {}, function (data) {
				handleCallback({
					data: data, callback: function (_callback5) {
						function callback(_x5) {
							return _callback5.apply(this, arguments);
						}

						callback.toString = function () {
							return _callback5.toString();
						};

						return callback;
					}(function (res) {
						// that.postNotification({
						// 	name: "KP_AUTH",
						// 	data: res
						// })
						callback(res);
					})
				});
			});
		},
		showLoading: function showLoading(_ref34) {
			var _ref34$text = _ref34.text,
			    text = _ref34$text === undefined ? '请稍后' : _ref34$text,
			    _ref34$delay = _ref34.delay,
			    delay = _ref34$delay === undefined ? 5000 : _ref34$delay;

			call('showLoading', { text: text, delay: delay }, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		hideLoading: function hideLoading() {
			call('showLoading', {}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 运营商一键登录
   * @param callback
   */
		pullUpMobileAuth: function pullUpMobileAuth(_ref35) {
			var _ref35$title = _ref35.title,
			    title = _ref35$title === undefined ? '一键认证' : _ref35$title,
			    _ref35$callback = _ref35.callback,
			    callback = _ref35$callback === undefined ? function () {} : _ref35$callback;

			var that = this;
			call('mobileAuth', { title: title }, function (data) {
				handleCallback({
					data: data, callback: function (_callback6) {
						function callback(_x6) {
							return _callback6.apply(this, arguments);
						}

						callback.toString = function () {
							return _callback6.toString();
						};

						return callback;
					}(function (res) {
						// that.postNotification({
						// 	name: "MOBILE_AUTH",
						// 	data: res
						// })
						callback(res);
					})
				});
			});
		},
		/**
   * 微信认证
   * @param callback
   */
		pullupWxAuth: function pullupWxAuth(_ref36) {
			var _ref36$state = _ref36.state,
			    state = _ref36$state === undefined ? 'default_state' : _ref36$state,
			    _ref36$callback = _ref36.callback,
			    callback = _ref36$callback === undefined ? function () {} : _ref36$callback;

			var that = this;
			call('wxLogin', {
				state: state
			}, function (data) {
				handleCallback({
					data: data, callback: function (_callback7) {
						function callback(_x7) {
							return _callback7.apply(this, arguments);
						}

						callback.toString = function () {
							return _callback7.toString();
						};

						return callback;
					}(function (res) {
						// that.postNotification({
						// 	name: "WX_AUTH",
						// 	data: res
						// })
						callback(res);
					})
				});
			});
		},
		/**
   * 微信订阅
   * @param scene
   * @param templateId
   * @param reserved
   * @param callback
   */
		wxSubscribe: function wxSubscribe(_ref37) {
			var scene = _ref37.scene,
			    templateId = _ref37.templateId,
			    reserved = _ref37.reserved,
			    _ref37$callback = _ref37.callback,
			    callback = _ref37$callback === undefined ? function () {} : _ref37$callback;

			call('wxLogin', {
				scene: scene,
				templateId: templateId,
				reserved: reserved
			}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 获取已经安装的离线包版本
   * @param callback
   */
		getOfflinePackInfo: function getOfflinePackInfo(_ref38) {
			var _ref38$callback = _ref38.callback,
			    callback = _ref38$callback === undefined ? function () {} : _ref38$callback;

			call('getOfflinePackInfo', {}, function (data) {
				handleCallback({ data: data, callback: callback });
			});
		},
		/**
   * 打开微信小程序
   * @param appid
   * @param miniProgramUserName
   * @param path
   */
		launchMiniProgram: function launchMiniProgram(_ref39) {
			var appid = _ref39.appid,
			    miniProgramUserName = _ref39.miniProgramUserName,
			    path = _ref39.path,
			    _ref39$callback = _ref39.callback,
			    callback = _ref39$callback === undefined ? function () {} : _ref39$callback;

			if (appid && miniProgramUserName && path) {
				console.log("确认执行", appid, miniProgramUserName, path);
				call('launchMiniProgram', {
					appid: appid,
					miniProgramUserName: miniProgramUserName,
					path: path
				}, function (data) {
					console.log("回调", data);
					handleCallback({ data: data, callback: callback });
				});
			} else {
				callback({ success: false, error: '9', errorMessage: '未给定必要参数' });
			}
		},
		shareMiniProgram: function shareMiniProgram(_ref40) {
			var appid = _ref40.appid,
			    miniProgramUserName = _ref40.miniProgramUserName,
			    path = _ref40.path,
			    webPageUrl = _ref40.webPageUrl,
			    _ref40$withShareTicke = _ref40.withShareTicket,
			    withShareTicket = _ref40$withShareTicke === undefined ? 'false' : _ref40$withShareTicke,
			    hdImageData = _ref40.hdImageData,
			    title = _ref40.title,
			    description = _ref40.description,
			    _ref40$callback = _ref40.callback,
			    callback = _ref40$callback === undefined ? function () {} : _ref40$callback;

			if (appid && miniProgramUserName && path && webPageUrl && hdImageData && title && description) {
				call('shareMiniProgram', {
					appid: appid,
					miniProgramUserName: miniProgramUserName,
					path: path,
					webPageUrl: webPageUrl,
					withShareTicket: withShareTicket,
					hdImageData: hdImageData,
					title: title,
					description: description
				}, function (data) {
					handleCallback({ data: data, callback: callback });
				});
			} else {
				callback({ success: false, error: '9', errorMessage: '未给定必要参数' });
			}
		},
		/**
   * 添加到系统日历
   */
		addToCalendar: function addToCalendar(_ref41) {
			var title = _ref41.title,
			    description = _ref41.description,
			    _ref41$location = _ref41.location,
			    location = _ref41$location === undefined ? '' : _ref41$location,
			    startTimestamp = _ref41.startTimestamp,
			    endTimestamp = _ref41.endTimestamp,
			    _ref41$hasAlert = _ref41.hasAlert,
			    hasAlert = _ref41$hasAlert === undefined ? 'false' : _ref41$hasAlert,
			    _ref41$beforeMinutes = _ref41.beforeMinutes,
			    beforeMinutes = _ref41$beforeMinutes === undefined ? '0' : _ref41$beforeMinutes,
			    _ref41$URL = _ref41.URL,
			    URL = _ref41$URL === undefined ? '' : _ref41$URL,
			    _ref41$callback = _ref41.callback,
			    callback = _ref41$callback === undefined ? function () {} : _ref41$callback;

			if (title && description && startTimestamp && endTimestamp) {
				call('addToCalendar', {
					title: title,
					description: description,
					location: location,
					startTimestamp: startTimestamp,
					endTimestamp: endTimestamp,
					hasAlert: hasAlert,
					beforeMinutes: beforeMinutes,
					URL: URL
				}, function (data) {
					handleCallback({ data: data, callback: callback });
				});
			} else {
				callback({ success: false, error: '9', errorMessage: '未给定必要参数' });
			}
		}
	};
}();

var ZgtlAppLogic = function () {
	var USER_KEY = 'ZGTL_CMN_USER';
	var TOKEN_KEY = 'ZGTL_CMN_TOKEN';
	var TOKEN_EXPIRE_KEY = 'ZGTL_CMN_TOKEN_EXPIRE';
	var JPUSH_MSG_KEY = 'JPUSH_MSG_LIST';
	var UNIVERSAL_LINK_KEY = 'UNI_LINK_MSG';
	var EVENT_USER_LOGOUT = 'EVENT_LOGOUT';
	var EVENT_USER_LOGIN = 'EVENT_LOGIN';
	var EVENT_DATE_SELECT = 'EVE_DAS';
	var EVENT_STATION_SELECT = 'EVE_STAS';
	var EVENT_CONTACT_SELECT = 'EVE_CNTA';
	var EVENT_JPUSH = 'ON_JPUSH';
	var EVENT_TAB_CLICK = 'TABCLICK';
	var EVENT_UNIVERSAL_LINK = 'UNILINK';
	var EVENT_APPEVENT = 'APPEVENT';

	function log() {
		for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
			args[_key3] = arguments[_key3];
		}

		console.log('[ZgtlAppLogic LOG]', args);
	}
	function sortMsg(a, b) {
		return b.time - a.time;
	}
	return {

		openLogin: function openLogin() {
			if (ZgtlUtils.isKp()) {
				ZgtlMpaasUtil.startH5App({
					verify: false,
					appId: "60000004",
					url: "login.html",
					showTitleBar: true
				});
			} else {
				ZgtlMpaasUtil.startH5App({
					verify: false,
					appId: "60000006",
					url: "/www/index.html#/login"
				});
			}
		},

		/**
   * 获取已登陆用户(本地缓存)
   * @param callback 返回用户数据
   */
		getCachedUser: function getCachedUser(_ref42) {
			var _ref42$success = _ref42.success,
			    success = _ref42$success === undefined ? function () {} : _ref42$success,
			    _ref42$error = _ref42.error,
			    error = _ref42$error === undefined ? function () {} : _ref42$error;

			ZgtlMpaasUtil.getAPDataStorage({
				key: USER_KEY,
				callback: function callback(data) {
					console.log("GECHACHED USER CALLBACK", data);
					if (!data.data) {
						error({ error: '9', success: false, errorMessage: '未找到数据' });
					} else {
						success(data.data);
					}
				}
			});
		},
		/**
   * 获取token
   * @param callback 返回数据
   */
		getCachedToken: function getCachedToken(_ref43) {
			var _ref43$success = _ref43.success,
			    success = _ref43$success === undefined ? function () {} : _ref43$success,
			    _ref43$error = _ref43.error,
			    error = _ref43$error === undefined ? function () {} : _ref43$error;

			ZgtlMpaasUtil.getAPDataStorage({
				key: TOKEN_KEY,
				callback: function callback(data) {
					if (!data.data) {
						error({ error: '9', success: false, errorMessage: '未找到数据' });
					} else {
						success(data.data);
					}
				}
			});
		},
		/**
   * 获取token过期时间戳
   * @param callback 返回数据
   */
		getCachedTokenExpireTime: function getCachedTokenExpireTime(_ref44) {
			var _ref44$success = _ref44.success,
			    success = _ref44$success === undefined ? function () {} : _ref44$success,
			    _ref44$error = _ref44.error,
			    error = _ref44$error === undefined ? function () {} : _ref44$error;

			ZgtlMpaasUtil.getAPDataStorage({
				key: TOKEN_EXPIRE_KEY,
				callback: function callback(data) {
					if (!data.data) {
						error({ error: '9', success: false, errorMessage: '未找到数据' });
					} else {
						success(data.data);
					}
				}
			});
		},
		/**
   * 获取OAuth授权码
   * @param appid 授权码
   * @param success
   * @param error
   */
		getOauthCode: function getOauthCode(_ref45) {
			var _ref45$appid = _ref45.appid,
			    appid = _ref45$appid === undefined ? '' : _ref45$appid,
			    _ref45$success = _ref45.success,
			    _success = _ref45$success === undefined ? function () {} : _ref45$success,
			    _ref45$error = _ref45.error,
			    _error = _ref45$error === undefined ? function () {} : _ref45$error;

			if (appid == '') {
				_error({ error: '9', success: false, errorMessage: '未给定appid' });
			} else {
				this.getCachedToken({
					success: function success(token) {
						ZgtlMpaasUtil.httpRequest({
							url: 'https://wifi.12306.cn/wifiapps/oauth2/getSessionCode?appid=' + appid,
							method: 'GET',
							callback: function callback(result) {
								if (result.error) {
									_error(result);
								} else {
									if (result.data.status == 0) {
										_success(result.data.data);
									} else {
										_error({ error: '9', success: false, errorMessage: result.data.message });
									}
								}
							}
						});
					},
					error: function error(err) {
						_error(err);
					}
				});
			}
		},
		/**
   * 获取Oauth授权码并跳转第三方页面
   * @param appid 授权码
   * @param codeParam 跳转参数名
   * @param toUrl 跳转地址
   * @param success
   * @param error
   */
		redirectOauthWeb: function redirectOauthWeb(_ref46) {
			var _ref46$appid = _ref46.appid,
			    appid = _ref46$appid === undefined ? '' : _ref46$appid,
			    _ref46$codeParam = _ref46.codeParam,
			    codeParam = _ref46$codeParam === undefined ? 'code' : _ref46$codeParam,
			    _ref46$toUrl = _ref46.toUrl,
			    toUrl = _ref46$toUrl === undefined ? '' : _ref46$toUrl,
			    _ref46$success = _ref46.success,
			    success = _ref46$success === undefined ? function () {} : _ref46$success,
			    _ref46$error = _ref46.error,
			    _error2 = _ref46$error === undefined ? function () {} : _ref46$error;

			this.getOauthCode({
				appid: appid,
				success: function success(code) {
					var url = toUrl + '?' + codeParam + '=' + code;
					ZgtlMpaasUtil.openOutURL({ url: url });
				},
				error: function error(err) {
					_error2(err);
				}
			});
		},
		/**
   * 刷新token
   * @param token
   * @param expireAt
   */
		refreshToken: function refreshToken(_ref47) {
			var _ref47$token = _ref47.token,
			    token = _ref47$token === undefined ? '' : _ref47$token,
			    _ref47$expireAt = _ref47.expireAt,
			    expireAt = _ref47$expireAt === undefined ? '' : _ref47$expireAt;

			ZgtlMpaasUtil.setAPDataStorage({ key: TOKEN_KEY, value: token });
			ZgtlMpaasUtil.setAPDataStorage({ key: TOKEN_EXPIRE_KEY, value: expireAt });
		},
		/**
   * App初始启动检查用户流程 & 注册极光监听
   */
		appInitCheckUserProcess: function appInitCheckUserProcess() {
			this.getCachedUser({
				success: function success(data) {
					console.log("APP INIT CHECK", data);
					if (data && data.logType != "R-W") {
						console.log("APP INIT CHECK NOT R-W");
						ZgtlMpaasUtil.getAPDataStorage({
							key: USER_KEY,
							callback: function callback(data) {
								if (data.data) {
									ZgtlMpaasUtil.unRegisterJPushAlias({ alias: data.data.id });
								}
							}
						});
						ZgtlMpaasUtil.unRegisterJPushAlias({ alias: '0000' });
						ZgtlMpaasUtil.postNotification({ name: EVENT_USER_LOGOUT });
						ZgtlMpaasUtil.removeAPDataStorage({ key: USER_KEY });
						ZgtlMpaasUtil.removeAPDataStorage({ key: TOKEN_EXPIRE_KEY });
						ZgtlMpaasUtil.removeAPDataStorage({ key: TOKEN_KEY });
					} else {
						ZgtlMpaasUtil.registerJPushAlias({ alias: data.id });
						this.getCachedTokenExpireTime({
							success: function success(time) {
								var currentTime = new Date().getTime();
								if (currentTime < time) {
									try {
										time = parseInt(time);
									} catch (e) {}
									if (time - currentTime < 86400000) {
										// <24h, 刷新
										log('token 有效 < 24h, 准备刷新');
										ZgtlAppLogic.getCachedToken({
											success: function success(cachedToken) {
												ZgtlMpaasUtil.httpRequest({
													url: 'https://wifi.12306.cn/wifiapps/authApi/refreshToken',
													method: 'POST',
													param: {
														token: cachedToken
													},
													callback: function callback(response) {
														if (!response.error && response.data.data) {
															var token = response.data.data.token;
															var expireAt = response.data.data.expireAt;
															ZgtlAppLogic.refreshToken({ token: token, expireAt: expireAt });
														} else {
															log('获取cachedToken错误,放弃刷新token');
														}
													}
												});
											},
											error: function error() {
												log('获取cachedToken错误,放弃刷新token');
											}
										});
									} else {
										log('token 有效, 准备探测userInfo接口');
										// 如果失败自然会被handle401,因此不用处理
										ZgtlMpaasUtil.httpRequest({
											url: 'https://wifi.12306.cn/wifiappas/appFrontEnd/v2/user/getUserInfo',
											method: 'GET'
										});
									}
								} else {
									// 过期,清空
									log('token 过期');
									ZgtlAppLogic.handleLogout();
								}
							}
						});
					}
				}
			});
		},

		/**
   * app 恢复事件
   */
		registerAppEvent: function registerAppEvent(_ref48) {
			var _ref48$onHide = _ref48.onHide,
			    onHide = _ref48$onHide === undefined ? function () {} : _ref48$onHide,
			    _ref48$onResume = _ref48.onResume,
			    onResume = _ref48$onResume === undefined ? function () {} : _ref48$onResume;

			ZgtlMpaasUtil.addNotifyListener({
				name: EVENT_APPEVENT,
				callback: function callback(data) {
					console.log('APP事件', data);
					if (data.type) {
						if (data.type == 'hide') {
							onHide();
						} else if (data.type == 'resume') {
							onResume();
						}
					} else {
						console.log('APP事件 无法获取type');
					}
				}
			});
		},
		/**
   * app Tab 被点击事件
   */
		registerTabClickEvent: function registerTabClickEvent(_ref49) {
			var _ref49$callback = _ref49.callback,
			    callback = _ref49$callback === undefined ? function (index) {} : _ref49$callback;

			ZgtlMpaasUtil.addNotifyListener({
				name: EVENT_TAB_CLICK,
				callback: function (_callback8) {
					function callback(_x8) {
						return _callback8.apply(this, arguments);
					}

					callback.toString = function () {
						return _callback8.toString();
					};

					return callback;
				}(function (data) {
					if (data.index != null && data.index != undefined) {
						callback(data.index + '');
					}
				})
			});
		},
		/**
   * 监听用户退出事件
   * @param 收到消息时的函数
   */
		registerLogoutEvent: function registerLogoutEvent(_ref50) {
			var _ref50$callback = _ref50.callback,
			    callback = _ref50$callback === undefined ? function () {} : _ref50$callback;

			ZgtlMpaasUtil.addNotifyListener({ name: EVENT_USER_LOGOUT, callback: callback });
		},
		/**
   * 监听用户登录事件
   * @param 收到消息时的函数
   */
		registerLoginEvent: function registerLoginEvent(_ref51) {
			var _ref51$callback = _ref51.callback,
			    callback = _ref51$callback === undefined ? function () {} : _ref51$callback;

			ZgtlMpaasUtil.addNotifyListener({ name: EVENT_USER_LOGIN, callback: callback });
		},
		/**
   * 监听日期选择事件
   * @param 收到消息时的函数
   */
		registerDateSelectEvent: function registerDateSelectEvent(_ref52) {
			var _ref52$callback = _ref52.callback,
			    callback = _ref52$callback === undefined ? function () {} : _ref52$callback;

			ZgtlMpaasUtil.addNotifyListener({ name: EVENT_DATE_SELECT, callback: callback });
		},
		/**
   * 监听车站选择事件
   * @param 收到消息时的函数
   */
		registerStationSelectEvent: function registerStationSelectEvent(_ref53) {
			var _ref53$callback = _ref53.callback,
			    callback = _ref53$callback === undefined ? function () {} : _ref53$callback;

			ZgtlMpaasUtil.addNotifyListener({ name: EVENT_STATION_SELECT, callback: callback });
		},
		/**
   * 联系人选择事件
   * @param 收到消息时候的回调函数
   */
		registerContactSelectEvent: function registerContactSelectEvent(_ref54) {
			var _ref54$callback = _ref54.callback,
			    callback = _ref54$callback === undefined ? function () {} : _ref54$callback;

			ZgtlMpaasUtil.addNotifyListener({
				name: EVENT_CONTACT_SELECT,
				callback: function (_callback9) {
					function callback(_x9) {
						return _callback9.apply(this, arguments);
					}

					callback.toString = function () {
						return _callback9.toString();
					};

					return callback;
				}(function (data) {
					if (data && ZgtlUtils.typeUtil.isString(data)) {
						try {
							data = JSON.parse(data);
						} catch (err) {
							// data = res;
							console.log('PARSE JSON ERR', err);
							callback({ error: '9', errorMessage: '消息参数异常' });
						}
					}
					if (data.error) {
						callback(data);
						return;
					}
					if (data.list) {
						var list = [];
						if (data.list && ZgtlUtils.typeUtil.isString(data.list)) {
							try {
								list = JSON.parse(data.list);
								callback(list);
							} catch (err) {
								console.log('PARSE JSON ERR', err);
								callback({ error: '9', errorMessage: '数据参数异常' });
							}
						} else {
							callback(data.list);
						}
					} else {
						callback([]);
					}
				})
			});
		},

		/**
   * 选择联系人事件
   * @param 联系人
   */
		handleContactSelect: function handleContactSelect(list) {
			ZgtlMpaasUtil.postNotification({
				name: EVENT_CONTACT_SELECT,
				data: { list: JSON.stringify(list) }
			});
		},
		/**
   * 极光推送用户点击确定的事件处理
   * @param 收到消息时的函数
   */
		registerJPushEvent: function registerJPushEvent(_ref55) {
			var _ref55$callback = _ref55.callback,
			    callback = _ref55$callback === undefined ? function () {} : _ref55$callback;

			ZgtlMpaasUtil.addNotifyListener({ name: EVENT_JPUSH, callback: callback });
		},
		/**
   * 处理日期选择事件
   * @param 日期
   */
		handleDateSelect: function handleDateSelect(_ref56) {
			var _ref56$date = _ref56.date,
			    date = _ref56$date === undefined ? '' : _ref56$date;

			ZgtlMpaasUtil.postNotification({ name: EVENT_DATE_SELECT, data: { date: date } });
		},

		/**
   * 处理车站选择页面
   * @param 车站
   */
		handleStationSelect: function handleStationSelect(_ref57) {
			var _ref57$stationName = _ref57.stationName,
			    stationName = _ref57$stationName === undefined ? '' : _ref57$stationName,
			    _ref57$stationTelecod = _ref57.stationTelecode,
			    stationTelecode = _ref57$stationTelecod === undefined ? '' : _ref57$stationTelecod;

			ZgtlMpaasUtil.postNotification({
				name: EVENT_STATION_SELECT,
				data: { stationName: stationName, stationTelecode: stationTelecode }
			});
		},
		/**
   * 处理401响应: 广播事件, 清空缓存
   */
		handle401: function handle401() {
			ZgtlMpaasUtil.getAPDataStorage({
				key: USER_KEY,
				callback: function callback(data) {
					if (data.data) {
						ZgtlMpaasUtil.unRegisterJPushAlias({ alias: data.data.id });
					}
				}
			});
			ZgtlMpaasUtil.unRegisterJPushAlias({ alias: '0000' });
			ZgtlMpaasUtil.postNotification({ name: EVENT_USER_LOGOUT });
			ZgtlMpaasUtil.removeAPDataStorage({ key: USER_KEY });
			ZgtlMpaasUtil.removeAPDataStorage({ key: TOKEN_EXPIRE_KEY });
			ZgtlMpaasUtil.removeAPDataStorage({ key: TOKEN_KEY });
		},
		/**
   * 用户登出处理: 广播事件, 清空缓存
   */
		handleLogout: function handleLogout() {
			ZgtlMpaasUtil.getAPDataStorage({
				key: USER_KEY,
				callback: function callback(data) {
					if (data.data) {
						ZgtlMpaasUtil.unRegisterJPushAlias({ alias: data.data.id });
					}
				}
			});
			ZgtlMpaasUtil.unRegisterJPushAlias({ alias: '0000' });
			ZgtlMpaasUtil.postNotification({ name: EVENT_USER_LOGOUT });
			ZgtlMpaasUtil.removeAPDataStorage({ key: USER_KEY });
			ZgtlMpaasUtil.removeAPDataStorage({ key: TOKEN_EXPIRE_KEY });
			ZgtlMpaasUtil.removeAPDataStorage({ key: TOKEN_KEY });
		},
		/**
   * 获取app 状态栏高度
   * @param callback 回调函数
   */
		getStatusBarHeight: function getStatusBarHeight(_ref58) {
			var _ref58$callback = _ref58.callback,
			    callback = _ref58$callback === undefined ? function () {} : _ref58$callback;

			ZgtlMpaasUtil.getAppBaseInfo({
				callback: function (_callback10) {
					function callback(_x10) {
						return _callback10.apply(this, arguments);
					}

					callback.toString = function () {
						return _callback10.toString();
					};

					return callback;
				}(function (data) {
					if (data.success == 'true' || data.success == true) {
						var height = data.barHeight || 0;
						callback(height);
					} else {
						callback(0);
					}
				})
			});
		},
		/**
   * 
   * @param 用户登录处理: 存储数据, 广播
   */
		handleLogin: function handleLogin(_ref59) {
			var responseData = _ref59.responseData,
			    _ref59$callback = _ref59.callback,
			    callback = _ref59$callback === undefined ? function () {} : _ref59$callback;

			if (!responseData) {
				callback({ error: '9', errorMessage: '无效参数 responseData' });
				return;
			} else {
				var userObj = responseData.user;
				var token = responseData.token;
				var expireAt = responseData.expireAt;

				userObj && ZgtlMpaasUtil.setAPDataStorage({
					key: USER_KEY,
					value: JSON.stringify(userObj)
				});
				token && ZgtlMpaasUtil.setAPDataStorage({
					key: TOKEN_KEY,
					value: token
				});
				expireAt && ZgtlMpaasUtil.setAPDataStorage({
					key: TOKEN_EXPIRE_KEY,
					value: expireAt
				});
				userObj && ZgtlMpaasUtil.registerJPushAlias({ alias: userObj.id });
				userObj && ZgtlMpaasUtil.registerMpaasUserId({ userId: userObj.id });
				ZgtlMpaasUtil.postNotification({ name: EVENT_USER_LOGIN });
			}
		},
		initUniversalLink: function initUniversalLink() {
			var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};

			if (ZgtlUtils.platform() == 'ios') {
				ZgtlMpaasUtil.getAPDataStorage({
					key: UNIVERSAL_LINK_KEY,
					callback: function callback(data) {
						console.log('UNIVERSAL LINK 缓存', data);
						if (data.data) {
							var url = data.data.url;
							var timestamp = data.data.timestamp;
							var now = new Date().getTime();
							var diff = now - timestamp;
							console.log('UniversalLink 时效判断', timestamp, now, diff, url);
							if (diff < 10000) {
								console.log('UniversalLink 缓存有效');
								ZgtlAppLogic.handleUniversalLink({ url: url });
							} else {
								console.log('UniversalLink 缓存无效');
							}
							// 移除key
							setTimeout(function () {
								ZgtlMpaasUtil.removeAPDataStorage({
									key: UNIVERSAL_LINK_KEY
								});
							}, 500);
						}
						ZgtlMpaasUtil.addNotifyListener({
							name: EVENT_UNIVERSAL_LINK,
							callback: function callback(res) {
								ZgtlMpaasUtil.getAPDataStorage({
									key: UNIVERSAL_LINK_KEY,
									callback: function callback(data) {
										console.log('测试查询 UNIVERSAL_LINK_KEY', data);
									}
								});
								console.log('UNIVERSAL LINK 事件', res);
								// 处理事件
								if (res && res.url) {
									ZgtlAppLogic.handleUniversalLink({ url: res.url });
								}
								// 移除key
								setTimeout(function () {
									ZgtlMpaasUtil.removeAPDataStorage({
										key: UNIVERSAL_LINK_KEY
									});
								}, 500);
							}
						});
					}
				});
			}
		},
		handleUniversalLink: function handleUniversalLink(_ref60) {
			var url = _ref60.url;

			if (url) {
				ZgtlMpaasUtil.openOutURL({
					url: url
				});
			}
		},

		/**
   * 极光推送处理
   */
		registerJPushHandler: function registerJPushHandler() {
			ZgtlMpaasUtil.addNotifyListener({
				name: 'ON_JPUSH',
				callback: function callback(data) {
					if (!data.error) {
						ZgtlAppLogic.processJPushMsgItem({ msg: data });
					}
				}
			});
		},
		/**
   * 从本地缓存获取jpush数据
   */
		getJPushMsgList: function getJPushMsgList(_ref61) {
			var _ref61$success = _ref61.success,
			    success = _ref61$success === undefined ? function () {} : _ref61$success,
			    _ref61$error = _ref61.error,
			    error = _ref61$error === undefined ? function () {} : _ref61$error;

			ZgtlMpaasUtil.getAPDataStorage({
				key: JPUSH_MSG_KEY,
				callback: function callback(data) {
					if (!data.data) {
						success([]);
					} else {
						if (data.data != null && data.data != undefined) {
							data.data.sort(sortMsg);
							success(data.data);
						} else {
							success(data.data);
						}
					}
				}
			});
		},
		clearJPushMsgItem: function clearJPushMsgItem() {
			ZgtlMpaasUtil.removeAPDataStorage({
				key: JPUSH_MSG_KEY
			});
		},

		/**
   * 维持极光推送列表最多20条数据,处理最新一条并打标记
   * @param success 成功回调
   * @param error 失败回调
   */
		processJPushMsgListAndHandleFirst: function processJPushMsgListAndHandleFirst(_ref62) {
			var _ref62$success = _ref62.success,
			    success = _ref62$success === undefined ? function () {} : _ref62$success,
			    _ref62$error = _ref62.error,
			    error = _ref62$error === undefined ? function () {} : _ref62$error;

			ZgtlAppLogic.getJPushMsgList({
				success: function success(msgList) {
					if (msgList.length > 0) {
						console.log('当前消息长度 ' + msgList.length);
						if (msgList.length > 20) {
							var diff = msgList.length - 20;
							console.log('准备删除前 ' + diff + '条消息');
							for (var i = 0; i < diff; i++) {
								console.log('删除...', msgList.pop());
							}
							ZgtlMpaasUtil.setAPDataStorage({
								key: JPUSH_MSG_KEY,
								value: JSON.stringify(msgList),
								callback: function callback(data) {
									if (data.error) {
										console.log(data);
										return;
									}
								}
							});
						}
						console.log('准备检查是否有未处理消息....');
						var msgItem = msgList[0];
						if (!msgItem.handleFlag) {
							console.log('找到未处理消息: ' + JSON.stringify(msgItem));
							ZgtlAppLogic.processJPushMsgItem({
								msg: msgItem
							});
						}
					}
				}
			});
		},

		removeJPushMsgItem: function removeJPushMsgItem(_ref63) {
			var _ref63$msgId = _ref63.msgId,
			    msgId = _ref63$msgId === undefined ? '' : _ref63$msgId,
			    _ref63$success = _ref63.success,
			    _success2 = _ref63$success === undefined ? function () {} : _ref63$success,
			    _ref63$error = _ref63.error,
			    _error3 = _ref63$error === undefined ? function () {} : _ref63$error;

			this.getJPushMsgList({
				success: function success(data) {
					var newList = [];
					var _iteratorNormalCompletion = true;
					var _didIteratorError = false;
					var _iteratorError = undefined;

					try {
						for (var _iterator = data[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
							var item = _step.value;

							if (item._j_msgid != msgId) {
								newList.push(item);
							}
						}
					} catch (err) {
						_didIteratorError = true;
						_iteratorError = err;
					} finally {
						try {
							if (!_iteratorNormalCompletion && _iterator.return) {
								_iterator.return();
							}
						} finally {
							if (_didIteratorError) {
								throw _iteratorError;
							}
						}
					}

					ZgtlMpaasUtil.setAPDataStorage({
						key: JPUSH_MSG_KEY,
						value: JSON.stringify(newList),
						callback: function callback(data) {
							if (!data.error) {
								_success2();
							} else {
								_error3(data);
							}
						}
					});
				},
				error: function error(err) {
					_error3(err);
				}
			});
		},
		isJPushMsgProcessable: function isJPushMsgProcessable(_ref64) {
			var _ref64$msg = _ref64.msg,
			    msg = _ref64$msg === undefined ? {} : _ref64$msg;

			// 开始处理
			var extras = msg.extras || { module: 'DEFAULT' };
			if (ZgtlUtils.platform() == 'android') {
				try {
					extras = JSON.parse(extras);
				} catch (e) {}
			}
			switch (extras.module) {
				case 'travel':
					var toPage = extras.toPage || ''; // CI(餐饮,trainDate, trainCode), TI(行程), TD(行程,travelId)
					switch (toPage) {
						case 'CI':
							//餐饮(若目标日期>=当前日期则跳转,否则不响应)
							var now = new Date();
							var curr_date = now.getDate();
							var curr_month = now.getMonth() + 1;
							if (curr_month < 10) {
								curr_month = '0' + curr_month;
							}
							if (curr_date < 10) {
								curr_date = '0' + curr_date;
							}
							var curr_year = now.getFullYear();
							var yyyyMMdd = curr_year + '' + curr_month + '' + curr_date;
							if (yyyyMMdd <= extras.trainDate) {
								return true;
							} else {
								return false;
							}
						case 'TD':
							// 行程明细
							return true;
						default:
							return false;
					}
				default:
					return false;
			}
		},

		processJPushMsgItem: function processJPushMsgItem(_ref65) {
			var _ref65$msg = _ref65.msg,
			    msg = _ref65$msg === undefined ? {} : _ref65$msg,
			    _ref65$success = _ref65.success,
			    success = _ref65$success === undefined ? function () {} : _ref65$success,
			    _ref65$error = _ref65.error,
			    error = _ref65$error === undefined ? function () {} : _ref65$error;

			// 原消息列表打标记并刷新列表
			ZgtlAppLogic.getJPushMsgList({
				success: function success(msgList) {
					if (msgList.length > 0) {
						var newMsgList = [];
						var foundMarkMsg = false;
						console.log('\u627E\u5230' + msgList.length + '\u6761\u6D88\u606F,\u51C6\u5907\u641C\u7D22\u5E76\u6253\u4E0A\u5904\u7406\u6807\u8BB0...');
						var _iteratorNormalCompletion2 = true;
						var _didIteratorError2 = false;
						var _iteratorError2 = undefined;

						try {
							for (var _iterator2 = msgList[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
								var item = _step2.value;

								if (msg._j_msgid == item._j_msgid) {
									console.log('\u627E\u5230\u6D88\u606F ' + item._j_msgid + ', \u51C6\u5907\u6253\u6807\u8BB0');
									item.handleFlag = true;
									item.handleTimestamp = new Date().getTime();
									foundMarkMsg = true;
								}
								newMsgList.push(item);
							}
						} catch (err) {
							_didIteratorError2 = true;
							_iteratorError2 = err;
						} finally {
							try {
								if (!_iteratorNormalCompletion2 && _iterator2.return) {
									_iterator2.return();
								}
							} finally {
								if (_didIteratorError2) {
									throw _iteratorError2;
								}
							}
						}

						if (foundMarkMsg) {
							console.log('找到消息, 准备更新消息列表');
							ZgtlMpaasUtil.setAPDataStorage({
								key: JPUSH_MSG_KEY,
								value: JSON.stringify(newMsgList),
								callback: function callback(data) {
									if (data.error) {
										error(data);
										return;
									}
								}
							});
						}
					}
				}
			});

			// 开始处理
			var extras = msg.extras || { module: 'DEFAULT' };
			if (ZgtlUtils.platform() == 'android') {
				try {
					extras = JSON.parse(extras);
				} catch (e) {}
			}
			switch (extras.module) {
				case 'travel':
					var toPage = extras.toPage || ''; // CI(餐饮,trainDate, trainCode), TI(行程), TD(行程,travelId)
					switch (toPage) {
						case 'CI':
							//餐饮(若目标日期>=当前日期则跳转,否则不响应)
							var now = new Date();
							var curr_date = now.getDate();
							var curr_month = now.getMonth() + 1;
							if (curr_month < 10) {
								curr_month = '0' + curr_month;
							}
							if (curr_date < 10) {
								curr_date = '0' + curr_date;
							}
							var curr_year = now.getFullYear();
							var yyyyMMdd = curr_year + '' + curr_month + '' + curr_date;
							if (yyyyMMdd <= extras.trainDate) {
								ZgtlMpaasUtil.startH5App({
									appId: OFFLINE_APPID_MAP.MEAL_MODULE,
									url: '/www/index.html#/add?boardTrainCode=' + extras.trainCode + '&trainDate=' + extras.trainDate
								});
							}
							break;
						case 'TD':
							// 行程明细
							ZgtlMpaasUtil.startH5App({
								appId: OFFLINE_APPID_MAP.TRAVEL_MODULE,
								url: '/www/index.html#/traveldetail?id=' + extras.travelId
							});
							break;
						default:
							error({ error: '9', success: 'false', errorMessage: '无可用处理' });
							break;
					}
					break;
				default:
					error({ error: '9', success: 'false', errorMessage: '无可用处理' });
					break;
			}
		},
		processBannerData: function processBannerData(_ref66) {
			var _ref66$banner = _ref66.banner,
			    banner = _ref66$banner === undefined ? {} : _ref66$banner,
			    _ref66$success = _ref66.success,
			    success = _ref66$success === undefined ? function () {} : _ref66$success,
			    _ref66$error = _ref66.error,
			    error = _ref66$error === undefined ? function () {} : _ref66$error;

			if (!banner.bannerType) {
				error({ error: '9', success: 'false', errorMessage: '未指定bannerType数据' });
			} else {
				var bannerType = banner.bannerType;
				switch (bannerType) {
					case '0':
						// nothing
						break;
					case '1':
						ZgtlMpaasUtil.openOutURL({ url: banner.bannerTurnUrl });
						break;
					case '2':
						var urlArray = banner.bannerTurnUrl.split('|');
						if (urlArray[0] == 'startH5App') {
							urlArray[0] = 'startApp';
						}
						switch (urlArray[0]) {
							case 'startApp':
								// startH5App|appid|url|verify
								if (urlArray.length != 4) {
									error({ error: '9', success: 'false', errorMessage: '参数不合法' });
								} else {
									// 20200109 修改,针对餐饮60000007且打开的是首页的(appid=60000007 && url='/www/index.html')
									if ('60000007' == urlArray[1] && '/www/index.html' == urlArray[2]) {
										//已登录且有行程
										ZgtlAppLogic.getCachedUser({
											success: function success(res) {
												ZgtlMpaasUtil.getAPDataStorage({
													key: 'CA_TRAVEL_' + res.loginName,
													callback: function callback(res) {
														if (res.data && res.data.length > 0) {
															ZgtlMpaasUtil.startH5App({
																verify: true,
																appId: urlArray[1],
																url: '/www/index.html#/index-with-travel'
															});
														} else {
															ZgtlMpaasUtil.startH5App({
																appId: urlArray[1],
																url: urlArray[2],
																verify: urlArray[3] == 'true'
															});
														}
													}
												});
											},
											error: function error() {
												ZgtlMpaasUtil.startH5App({
													appId: urlArray[1],
													url: urlArray[2],
													verify: urlArray[3] == 'true'
												});
											}
										});
									} else {
										ZgtlMpaasUtil.startH5App({
											appId: urlArray[1],
											url: urlArray[2],
											verify: urlArray[3] == 'true'
										});
									}
								}
								break;
							case 'openStationNav':
								ZgtlMpaasUtil.openStationNav({});
								break;
							case 'redirectOauthWeb':
								// redirectOauthWeb|appid|toUrl|code
								if (urlArray.length != 4) {
									error({ error: '9', success: 'false', errorMessage: '参数不合法' });
								} else {
									ZgtlMpaasUtil.redirectOauthWeb({
										appid: urlArray[1],
										toUrl: urlArray[2],
										codeParam: urlArray[3]
									});
								}
								break;
							case 'launchMiniProgram':
								//launchMiniProgram|appid|miniProgramUserName|path
								if (urlArray.length != 4) {
									error({ error: '9', success: 'false', errorMessage: '参数不合法' });
								} else {
									ZgtlMpaasUtil.launchMiniProgram({
										appid: urlArray[1],
										miniProgramUserName: urlArray[2],
										path: urlArray[3],
										callback: function callback(res) {
											console.log("执行结果", res);
										}
									});
								}
								break;
							default:
								error({ error: '9', success: 'false', errorMessage: '无可用处理' });
								break;
						}
						break;
					default:
						error({ error: '9', success: 'false', errorMessage: '无可用处理' });
						break;
				}
			}
		},
		/**
   * 处理快捷菜单
   * @param 
   */
		processQuickMenu: function processQuickMenu(_ref67) {
			var _ref67$success = _ref67.success,
			    success = _ref67$success === undefined ? function () {} : _ref67$success,
			    _ref67$error = _ref67.error,
			    error = _ref67$error === undefined ? function () {} : _ref67$error;

			ZgtlMpaasUtil.getAPDataStorage({
				key: 'ICON_MENU_SELECT',
				callback: function callback(res) {
					if (res.data && res.data.timestamp) {
						console.log('查询到quickMenu数据', res.data);
						var now = new Date().getTime();
						var diff = now - res.data.timestamp;
						if (diff < 10000) {
							// 处理请求并删除快捷菜单
							switch (res.data.type) {
								case 'icon':
									console.log('处理类型', res.data.type);
									switch (res.data.appId) {
										case '60000010':
											ZgtlMpaasUtil.startH5App({
												appId: res.data.appId,
												url: '/www/index.html'
											});
											success({ success: true });
											break;
										case '60000013':
											ZgtlMpaasUtil.startH5App({
												appId: res.data.appId,
												url: '/www/index.html'
											});
											success({ success: true });
											break;
										case '60000007':
											// 20200110 处理为新餐饮首页
											ZgtlAppLogic.getCachedUser({
												success: function success(cacheRes) {
													ZgtlMpaasUtil.getAPDataStorage({
														key: 'CA_TRAVEL_' + cacheRes.loginName,
														callback: function callback(dsRes) {
															if (dsRes.data && dsRes.data.length > 0) {
																ZgtlMpaasUtil.startH5App({
																	verify: true,
																	appId: '60000007',
																	url: '/www/index.html#/index-with-travel'
																});
															} else {
																ZgtlMpaasUtil.startH5App({
																	appId: '60000007',
																	url: '/www/index.html'
																});
															}
														}
													});
												},
												error: function error() {
													ZgtlMpaasUtil.startH5App({
														appId: '60000007',
														url: '/www/index.html'
													});
												}
											});
											success({ success: true });
											break;
										case '60000009':
											ZgtlMpaasUtil.startH5App({
												appId: res.data.appId,
												url: '/www/index.html'
											});
											success({ success: true });
											break;
										default:
											error({ error: '9', success: 'false', errorMessage: '无可用处理' });
											break;
									}
									break;
								default:
									error({ error: '9', success: 'false', errorMessage: '无可用处理' });
									break;
							}
						} else {
							console.log('时间差距太大,抛弃', res.data);
						}
						ZgtlMpaasUtil.removeAPDataStorage({
							key: 'ICON_MENU_SELECT'
						});
						setTimeout(function () {
							window.ZgtlMpaasUtil.postNotification({
								name: 'H_HI',
								data: {}
							});
						}, 100);
					}
				}
			});
		}
	};
}();

(function () {
	/**
  * 应用全局初始化的地方
  */
	function init() {}
	init();
})();